"""
---------------------------------------------------------------------
- File: security.py
- Date: 2025/11/17
- Author: yangzhide
- Email: xxzjyzd@126.com
- Description: 安全相关的函数
---------------------------------------------------------------------
"""

from fastapi.security import OAuth2PasswordBearer
from pwdlib import PasswordHash

password_hash = PasswordHash.recommended()
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/system/login")


def verify_password(plain_password: str, hashed_password: str) -> bool:
    """
    验证密码是否正确
    """
    return password_hash.verify(plain_password, hashed_password)


def get_password_hash(password: str) -> str:
    """
    获取密码的哈希值
    """
    return password_hash.hash(password)